package com.tange.ai.iot.client.gnssa.utils;

import android.app.Activity;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;

public class BleUtil {
    public BleUtil() {
    }

    public static void enableBluetooth(Activity activity, int requestCode) {
        Intent intent = new Intent("android.bluetooth.adapter.action.REQUEST_ENABLE");
        activity.startActivityForResult(intent, requestCode);
    }

    public static boolean isSupportBle(Context context) {
        if (context != null && context.getPackageManager().hasSystemFeature("android.hardware.bluetooth_le")) {
            BluetoothManager manager = (BluetoothManager)context.getSystemService("bluetooth");
            return manager.getAdapter() != null;
        } else {
            return false;
        }
    }

    public static boolean isBleEnable(Context context) {
        if (!isSupportBle(context)) {
            return false;
        } else {
            BluetoothManager manager = (BluetoothManager)context.getSystemService("bluetooth");
            return manager.getAdapter().isEnabled();
        }
    }
}
